package com.example.asapp.demo.article;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
@RestController
@Slf4j
@RequestMapping("/api/demo/article")
public class ArticleApi {

    @Autowired
    ArticleService articleService;

    @GetMapping("listQuery")
    public List<Article> findAll(){
        return articleService.findAll();
    }

    @PostMapping("save")
    public Article saveOne(@RequestBody Article article){
        return articleService.saveOne(article);
    }

    @DeleteMapping("delete/{id}")
    public void deleteOne(@PathVariable String id){
       articleService.deleteByPrimary(id);
    }



}
